<?php

$sql="SELECT *
FROM `users`
WHERE DATE_ADD( last_action, INTERVAL 15
MINUTE ) >= NOW() AND UserSession != '' ORDER BY UserID";
$result= mysql_query($sql) or die(mysql_error());

echo '<b>User online:</b> ';
//echo "<h2>".$sql."</h2>";
$string = "";
while ($line = mysql_fetch_array($result)) {

	$string = $string.$line["UserName"].', ';
}
echo substr($string,0, -2);

?>